<template>
  <div class="app-container">
      <el-form
        ref="dataForm"
        :model="temp"
        :rules="rules"
        label-position="right"
        label-width="150px"
        style="width: 700px; margin:0 auto;margin-top:5%"
      >
        <el-form-item label="新用户注册奖励：" prop="initXkb">
          <el-input placeholder="新用户注册奖励" v-model="temp.initXkb" style="width:500px;float:left"/>
        </el-form-item>
      </el-form>
      <el-button
        size="medium"
        class="filter-item"
        type="success"
        style="display:block;margin:0 auto"
        @click="signIn"
      >
        保存并发布
      </el-button>
  </div>
</template>

<script>
// 异步请求 delLly
import Vue from 'vue'
import { getData,update } from '@/api/registration/index'

export default {
  inject:["reload"],
  data() {
    return {
      temp: {
      },
      rules:{
          initXkb:[{
              required: true, message: '不能为空且必须为数字'
          }],
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList(){
        getData().then(res=>{
            this.temp=res.data
        })
    },
    signIn(){
        this.temp.initXkb=Number(this.temp.initXkb)
        update(this.temp).then(res=>{
            if(res.code==='200'){
                this.$notify({
                    title: '成功',
                    message: '修改成功',
                    type: 'success',
                    duration: 2000
                })
                this.getList()
            }else{
                this.$notify({
                    title: '失败',
                    message: '修改失败',
                    type: 'danger',
                    duration: 2000
                })
                this.getList()
            }
        })
    }
  }
}
</script>
<style>
</style>
